<?php

namespace Plugin\Alarm\Event;

class WorkAcceptEvent extends AbstractWorkHandleEvent
{
    public array $work;
    public int $standId;
    public int $fromUserId;
    public int $status;
    public string $remark;
    public function __construct($work, $standId, $fromUserId, int $status, $remark) {
        $this->work = $work;
        $this->standId = $standId;
        $this->fromUserId = $fromUserId;
        $this->status = $status;
        $this->remark = $remark;
    }

    public function getTitle(): string
    {
        return '工单转派';
    }

    public function getTargetUsers(): array
    {
        return [$this->fromUserId];
    }

    public function getMessage(): string
    {
        return '#' . $this->work['id'] . ' ' . $this->work['title'] .
            ($this->status == 2 ? '工单转派已被接受。' : '工单转派已被拒绝。') . $this->remark;
    }

    public function getLevel(): int
    {
        return 1;
    }
}